<?php
require_once 'init.php';
if($sessionID){
	$xml = new UserXml($loginDB);
	$user = $xml->getUserByID($sessionID);
	if(!empty($user)){
		if($user['name']==$sessionName&&$user['passwd']==$sessionPasswd){
			header('location:index.php');
			exit;
		}
	}
}
$name = isset($_POST['name'])?$_POST['name']:'';
$passwd = isset($_POST['passwd'])?$_POST['passwd']:'';
if($name!=''&&$passwd!=''){
	$xml = new UserXml($loginDB);
	if($user = $xml->hasUser($name,$passwd)){
		Tool::_setSession('userID',$user['id']);
		Tool::_setSession('userName',$user['name']);
		Tool::_setSession('passwd',$user['password']);
		header('location:index.php');
		exit;
	}
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>thank login</title>
	<link rel="stylesheet" href="css/styles.css" />
	<!--[if lt IE 9]>
		<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
</head>
<body>
	<div id="formContainer">
		<form id="login" method="post" action="login.php">
			<input type="text" name="name" id="loginEmail" />
			<input type="password" name="passwd" id="loginPass" />
			<input type="submit" name="submit" value="Login" />
		</form>
	</div>
	<footer>
		<h2><i>Thank Studio:</i>后台管理</h2>
		<a class="tzine" href="http://www.amo.so">thanks to<i>aimo<b>&aimodisign</b></i></a>
	</footer>
	<!-- JavaScript includes -->
<!--	<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
	<script src="js/script.js"></script>-->
</body>
</html>
